﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ERP.Business.DataTypes.Employee.Vacations
{
    [System.Runtime.Serialization.DataContract]
    [Serializable]
    public class Leave : BaseTypes.BaseType
    {
        private DateTime m_Date;
        private DateTime m_StartHour;
        private DateTime m_EndHour;
        private float m_Duration;
        private LeaveStatus m_Status = LeaveStatus.None;
        private LeaveType m_Type = LeaveType.None;

        [System.Runtime.Serialization.DataMember]
        public DateTime Date
        {
            get { return m_Date; }
            set { m_Date = value; }
        }
        [System.Runtime.Serialization.DataMember]
        public DateTime StartHour
        {
            get { return m_StartHour; }
            set { m_StartHour = value; }
        }
        [System.Runtime.Serialization.DataMember]
        public DateTime EndHour
        {
            get { return m_EndHour; }
            set { m_EndHour = value; }
        }
        [System.Runtime.Serialization.DataMember]
        public float Duration
        {
            get { return m_Duration; }
            set { m_Duration = value; }
        }
        [System.Runtime.Serialization.DataMember]
        public LeaveStatus Status
        {
            get { return m_Status; }
            set { m_Status = value; }
        }
        [System.Runtime.Serialization.DataMember]
        public LeaveType Type
        {
            get { return m_Type; }
            set { m_Type = value; }
        }

        public override int Compare(object x, object y)
        {
            if (ERP.Framework.Components.ComparingHelper.ComapringManager.CompareTypes(x, y))
                return ((Leave)x).Date.CompareTo(((Leave)y).Date);
            return -1;
        }

        public override object Clone()
        {
            Leave l = new Leave();
            l.Date = Date;
            l.Duration = Duration;
            l.EndHour = EndHour;
            l.ID = ID;
            l.StartHour = StartHour;
            l.Status = Status;
            l.Type = Type;
            return l;
        }
    }
}
